package com.sky.controller.admin;

import com.sky.dto.OrdersCancelDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.entity.Orders;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.OrderService;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/order")
@Slf4j
public class OrderController {

    @Autowired
    private OrderService orderService;
@GetMapping("/conditionSearch")
    public Result<PageResult> conditionSearch(OrdersPageQueryDTO ordersPageQueryDTO){

   PageResult pageResult= orderService.conditionSearch(ordersPageQueryDTO);
    return  Result.success(pageResult);
}
@GetMapping("/statistics")
 public Result<OrderStatisticsVO> statistics(){

    OrderStatisticsVO od=orderService.statistics();
    return Result.success(od);
}
@PutMapping("/confirm")
    public Result confirm(@RequestBody Orders orders){
    orderService.confirm(orders);
    return  Result.success();
}
@GetMapping("/details/{id}")
    public Result<OrderVO> details(@PathVariable Long id){
  OrderVO orderVO  =orderService.details(id);

return  Result.success(orderVO);
}
@PutMapping("/rejection")
    public Result rejection(@RequestBody OrdersRejectionDTO ordersRejectionDTO){
    orderService.rejection(ordersRejectionDTO);
    return Result.success();
}
@PutMapping("/cancel")
    public Result cancel(@RequestBody OrdersCancelDTO ordersCancelDTO){

    orderService.cancel(ordersCancelDTO);
    return Result.success();
}
@PutMapping("/delivery/{id}")
    public Result delivery(@PathVariable Long id){
    orderService.delivery(id);
    return Result.success();
}
@PutMapping("complete/{id}")
    public Result complete(@PathVariable Long id){
    orderService.complete(id);

    return Result.success();
}
}
